import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:${USER}
 * Date:${YEAR}-${MONTH}-${DAY}
 * ${TIME}
 */
public class Main {
    static int n;
    static int[] arr;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int r,l;
        n=in.nextInt();
        l=in.nextInt();r=in.nextInt();
         arr=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=in.nextInt();
        }
        Arrays.sort(arr);
        System.out.println(Func(r)-Func(l-1));
    }
    static long Func(int x){
        long ret=0;
        int left=0,right=0;
        while(right<n){
            while(arr[right]-arr[left]>x)left++;
            ret+=right-left;
            right++;
        }
        return ret;
    }
}